package xdpm.nhom16.DAO;

import xdpm.nhom16.DTO.TuKhoaDiaDiemDTO;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class TuKhoaDiaDiemDAO extends AbstractTuKhoaDAO<TuKhoaDiaDiemDTO> {

	public static final String COLUMN_PARENT = "MaTenDiaDiem";
	public static final String COLUMN_TUKHOA = "TuKhoaTenDiaDiem";
	private static final String COLUMN_ID = "MaTuKhoaTenDiaDiem";
	private static final String[] NAME_COLUMNS = new String[] { COLUMN_ID, COLUMN_TUKHOA,
			COLUMN_PARENT };
	private static final String TABLE_NAME = "TUKHOADIADIEM";

	public TuKhoaDiaDiemDAO(SQLiteDatabase db) {
		super(db);
		// TODO Auto-generated constructor stub
	}

	@Override
	protected String getTableName() {
		return TABLE_NAME;
	}

	@Override
	protected String getNameColumnId() {
		return COLUMN_ID;
	}

	@Override
	protected String[] getNameColumns() {
		return NAME_COLUMNS;
	}

	@Override
	protected TuKhoaDiaDiemDTO cusorToDTO(Cursor cursor) {
		int id = cursor.getInt(0);

		TuKhoaDiaDiemDTO dto = new TuKhoaDiaDiemDTO();
		dto.setMaTuKhoaDiaDiem(id);
		if (!cursor.isNull(1))
		dto.setTuKhoaDiaDiem(cursor.getString(1));
		if (!cursor.isNull(2))
		dto.setMaTenDiaDiem(cursor.getInt(2));
		return dto;
	}

	@Override
	protected String getNameColumnTuKhoa() {
		// TODO Auto-generated method stub
		return COLUMN_TUKHOA;
	}

	@Override
	protected String getNameColumnRefIdParent() {
		// TODO Auto-generated method stub
		return COLUMN_PARENT;
	}
}